// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

var current_page_settings = new Hash();

function getValue(key) 
{
  return current_page_settings.get(key);
}

function setValue(key,value)
{
  current_page_settings.set(key,value);
}

function lite_fetion_state_name(state)
{
  if(state == 'SUCCESS')
  {
      return "成功";
  }
  if(state == 'BUDDY_EXISTS')
  {
      return "好友已经存在";
  }
  if(state == 'PASSWORD_NOT_MATCH')
  {
      return "密码错误";
  }
  if(state == 'PORTRAIT_NOT_FOUND')
  {
      return "请求失败";
  }
  if(state == 'USER_INVALID')
  {
      return "账号无效";
  }
  if(state == 'USER_NOT_FOUND')
  {
      return "未开通飞信";
  }
  if(state == 'USER_SUSPEND')
  {
      return "已经欠费";
  }
  if(state == 'VERIFY_FAILED')
  {
      return "验证码错误";
  }
  if(state == 'REQUEST_FAILED')
  {
      return "请求失败";
  }  
  return state;
}


function fetion_sm_state_name(state)
{
  if(state == 'SUCCESS')
  {
      return "成功";
  }
  if(state == 'SSI_AUTH_FAIL')
  {
      return "你输入的手机号或者密码不对";
  }
  if(state == 'SSI_CONNECT_FAIL')
  {
      return "SSI连接失败";
  }
  if(state == 'SIPC_CONNECT_FAIL')
  {
      return "SIPC服务器连接失败";
  }
  if(state =='SIPC_AUTH_FAIL')
  {
      return "SIPC验证失败";
  }
  if(state == 'SSI_NEED_VERIFY')
  {
      return "需要验证";
  }
  if(state == 'SSI_VERIFY_FAIL')
  {
      return "验证码不正确";
  }
  if(state == 'cmcc_mobile_requested')
  {
      return "手机号必须是中国移动的";
  }
  if(state == 'mobile_requested')
  {
      return "手机号必填";
  }
  if(state == 'password_requested')
  {
      return "密码不正确";
  }
  if(state == 'content_requested')
  {
      return "短信内容必填";
  }
  if(state == 'NO_SUCH_FRIEND')
  {
      return "无法发送消息给非好友";
  }
  if(state == "OHTER_ERROR")
  {
      return "飞信服务器正在维护中，请稍候重试";
  }
  return state;
}

function add_favorite(sURL, sTitle)
{
  try
  {
    window.external.addFavorite(sURL, sTitle);
  }
  catch (e)
  {
    try
    {
      window.sidebar.addPanel(sTitle, sURL, "");
    }
    catch (e)
    {
      alert("加入收藏失败，有劳您手动添加。");
    }
  }
}

function set_to_home()
{
  if (document.all)
  {
    document.body.style.behavior='url(#default#homepage)';
    document.body.setHomePage('http://www.mytusi.com');
  
  }
  else if (window.sidebar)
  {
    if(window.netscape)
  {
    try
    { 
      netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
    } 
    catch (e) 
    { 
      alert( "该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true" ); 
    }
  }
    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
    prefs.setCharPref('browser.startup.homepage','http://www.mytusi.com');
  }
}

function copy_to_clipboard(s)  
{ 
  if (window.clipboardData) {
		window.clipboardData.setData("Text",s);
	}
	else
	{  
		var flashcopier = 'flashcopier';
		if(!document.getElementById(flashcopier)) {
		  var divholder = document.createElement('div');
		  divholder.id = flashcopier;
		  document.body.appendChild(divholder);
		}
		document.getElementById(flashcopier).innerHTML = '';
		var divinfo = '<embed src="/swf/clipboard.swf" FlashVars="clipboard='+encodeURIComponent(s)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';
		document.getElementById(flashcopier).innerHTML = divinfo;
	}
	alert("\r\n信息："+s+"\r\n\r\n恭喜您，您需要的信息已经被成功复制到剪贴板了！\r\n\r\n贴心小提示：(1) 按 Ctrl+v 可以将上面信息粘贴到您指定的位置。\r\n\r\n                        (2) 按空格键可迅速关闭本提示框");
}


    
function debug(string) {
  $('debugger').insert('  ' + string + "<br>");
}

function clear_debug() {
  $('debugger').update('');
}